package com.ghn.cocknovel.view;

import android.content.Context;
import android.view.View;
import android.widget.TextView;

import androidx.annotation.ColorInt;
import androidx.annotation.NonNull;

import com.ghn.cocknovel.R;

/**
 * admin
 * 2018/11/13
 * content :
 */
public class DialogMessage extends BaseDialog {

    private TextView messageContent;
    private TextView messageTitleTv;

    public DialogMessage(@NonNull Context context) {
        super(context);
    }

    @Override
    public int getChildView() {
        return R.layout.dialog_message;
    }

    @Override
    protected void initData() {
        messageContent = findViewById(R.id.dialog_message_content);
        messageTitleTv = findViewById(R.id.dialog_message_title_tv);
        setBaseDialogClickListener(new baseDialogClickListener() {
            @Override
            public void YesClick(View view) {
                dismiss();
                if (clickListener != null) {
                    clickListener.yesClick(DialogMessage.this);
                }
            }

            @Override
            public void notClick(View view) {
                dismiss();
                if (clickListener != null) {
                    clickListener.notClick(DialogMessage.this);
                }
            }
        });
    }

    public DialogMessage setContext(String str) {
        messageContent.setText(str);
        return this;
    }

    public DialogMessage setMessageContentColor(@ColorInt int color) {
        messageContent.setTextColor(color);
        return this;
    }

    public DialogMessage setMessageTitle(String str) {
        messageTitleTv.setVisibility(View.VISIBLE);
        messageTitleTv.setText(str);
        return this;
    }

    @Override
    public DialogMessage setYesVisibility(int visibility) {
        super.setYesVisibility(visibility);
        return this;
    }

    @Override
    public DialogMessage setNotVisibility(int visibility) {
        super.setNotVisibility(visibility);
        return this;
    }

    public DialogMessage setYesText(String text) {
        super.setYesText(text);
        return this;
    }

    @Override
    public DialogMessage setNotText(String text) {
        super.setNotText(text);
        return this;
    }

    public DialogMessage setBaseCancelable(boolean flag) {
        super.setBaseCancelable(flag);
        return this;
    }

    private DialogClickListener clickListener;

    public DialogMessage setClickListener(DialogClickListener clickListener) {
        this.clickListener = clickListener;
        return this;
    }

}
